// =====================================================================
//
//  This file is part of the Microsoft Dynamics CRM SDK code samples.
//
//  Copyright (C) Microsoft Corporation.  All rights reserved.
//
//  This source code is intended only as a supplement to Microsoft
//  Development Tools and/or on-line documentation.  See these other
//  materials for detailed information regarding Microsoft code samples.
//
//  THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//  PARTICULAR PURPOSE.
//
// =====================================================================
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization;

namespace Microsoft.Xrm.Sdk.Metadata
{
	[DataContract(Name = "EntityMetadata", Namespace = Microsoft.Xrm.Sdk.XmlNamespaces.V5.Metadata)]
	public sealed class EntityMetadata : MetadataBase
	{
		#region Fields
		private int? _activityTypeMask;
		private AttributeMetadata[] _attributes;
		private bool? _canTriggerWorkflow;
		private Label _description;
		private Label _displayCollectionName;
		private Label _displayName;
		private bool? _isDocumentMangementEnabled;

		private bool? _isActivity;
		private bool? _isActivityParty;
		private BooleanManagedProperty _isAuditEnabled;
		private bool? _isAvailableOffline;
		private bool? _isChildEntity;
		private BooleanManagedProperty _isValidForQueue;
		private BooleanManagedProperty _isConnectionsEnabled;
		private string _iconLargeName;
		private string _iconMediumName;
		private string _iconSmallName;
		private bool? _isCustomEntity;
		private BooleanManagedProperty _isCustomizable;
		private BooleanManagedProperty _isRenameable;
		private BooleanManagedProperty _isMappable;
		private BooleanManagedProperty _isDuplicateDetectionEnabled;
		private bool? _isImportable;
		private bool? _isIntersect;
		private BooleanManagedProperty _isMailMergeEnabled;
		private bool? autoRouteToOwnerQueue;
		private bool? _isEnabledForCharts;
		private bool? _isValidForAdvancedFind;
		private BooleanManagedProperty _isVisibleInMobile;
		private string _logicalName;
		private ManyToManyRelationshipMetadata[] _manyToManyRelationships;
		private OneToManyRelationshipMetadata[] _manyToOneRelationships;
		private int? _objectTypeCode;
		private OneToManyRelationshipMetadata[] _oneToManyRelationships;
		private OwnershipTypes? _ownershipType;
		private string _primaryNameAttribute;
		private string _primaryIdAttribute;
		private SecurityPrivilegeMetadata[] _privileges;
		private string _recurrenceBaseEntityLogicalName;
		private string _reportViewName;
		private string _schemaName;
		private string _physicalName;
		private int? _workflowSupport;
		private bool? _isManaged;
		private bool? _isReadingPaneEnabled;

		private BooleanManagedProperty _canCreateAttributes;
		private BooleanManagedProperty _canCreateForms;
		private BooleanManagedProperty _canCreateCharts;
		private BooleanManagedProperty _canCreateViews;
		private BooleanManagedProperty _canBeRelatedEntityInRelationship;
		private BooleanManagedProperty _canBePrimaryEntityInRelationship;
		private BooleanManagedProperty _canBeInManyToMany;
		private BooleanManagedProperty _canModifyAdditionalSettings;
		#endregion

		[DataMember]
		public int? ActivityTypeMask
		{
			get { return this._activityTypeMask; }
			set { this._activityTypeMask = value; }
		}

		[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
		[DataMember]
		public AttributeMetadata[] Attributes
		{
			get { return this._attributes; }
			internal set { this._attributes = value; }
		}

		[DataMember]
		public bool? AutoRouteToOwnerQueue
		{
			get { return this.autoRouteToOwnerQueue; }
			set { this.autoRouteToOwnerQueue = value; }
		}

		[DataMember]
		public bool? CanTriggerWorkflow
		{
			get { return this._canTriggerWorkflow; }
			internal set { this._canTriggerWorkflow = value; }
		}

		[DataMember]
		public Label Description
		{
			get { return this._description; }
			set { this._description = value; }
		}

		[DataMember]
		public Label DisplayCollectionName
		{
			get { return this._displayCollectionName; }
			set { this._displayCollectionName = value; }
		}

		[DataMember]
		public Label DisplayName
		{
			get { return this._displayName; }
			set { this._displayName = value; }
		}

		[DataMember]
		public bool? IsDocumentManagementEnabled
		{
			get { return this._isDocumentMangementEnabled; }
			set { this._isDocumentMangementEnabled = value; }
		}

		[DataMember]
		public bool? IsActivity
		{
			get { return this._isActivity; }
			set { this._isActivity = value; }
		}

		[DataMember]
		public bool? IsActivityParty
		{
			get { return this._isActivityParty; }
			set { this._isActivityParty = value; }
		}

		[DataMember]
		public BooleanManagedProperty IsAuditEnabled
		{
			get { return this._isAuditEnabled; }
			set { this._isAuditEnabled = value; }
		}

		[DataMember]
		public bool? IsAvailableOffline
		{
			get { return this._isAvailableOffline; }
			set { this._isAvailableOffline = value; }
		}

		[DataMember]
		public bool? IsChildEntity
		{
			get { return this._isChildEntity; }
			internal set { this._isChildEntity = value; }
		}

		[DataMember]
		public BooleanManagedProperty IsValidForQueue
		{
			get { return this._isValidForQueue; }
			set { this._isValidForQueue = value; }
		}

		[DataMember]
		public BooleanManagedProperty IsConnectionsEnabled
		{
			get { return this._isConnectionsEnabled; }
			set { this._isConnectionsEnabled = value; }
		}

		[DataMember]
		public string IconLargeName
		{
			get { return this._iconLargeName; }
			set { this._iconLargeName = value; }
		}

		[DataMember]
		public string IconMediumName
		{
			get { return this._iconMediumName; }
			set { this._iconMediumName = value; }
		}

		[DataMember]
		public string IconSmallName
		{
			get { return this._iconSmallName; }
			set { this._iconSmallName = value; }
		}

		[DataMember]
		public bool? IsCustomEntity
		{
			get { return this._isCustomEntity; }
			internal set { this._isCustomEntity = value; }
		}

		[DataMember]
		public BooleanManagedProperty IsCustomizable
		{
			get { return this._isCustomizable; }
			set { this._isCustomizable = value; }
		}

		[DataMember]
		public BooleanManagedProperty IsRenameable
		{
			get { return this._isRenameable; }
			set { this._isRenameable = value; }
		}

		[DataMember]
		public BooleanManagedProperty IsMappable
		{
			get { return this._isMappable; }
			set { this._isMappable = value; }
		}

		[DataMember]
		public BooleanManagedProperty IsDuplicateDetectionEnabled
		{
			get { return this._isDuplicateDetectionEnabled; }
			set { this._isDuplicateDetectionEnabled = value; }
		}

		[DataMember]
		public BooleanManagedProperty CanCreateAttributes
		{
			get { return this._canCreateAttributes; }
			set { this._canCreateAttributes = value; }
		}

		[DataMember]
		public BooleanManagedProperty CanCreateForms
		{
			get { return this._canCreateForms; }
			set { this._canCreateForms = value; }
		}

		[DataMember]
		public BooleanManagedProperty CanCreateViews
		{
			get { return this._canCreateViews; }
			set { this._canCreateViews = value; }
		}

		[DataMember]
		public BooleanManagedProperty CanCreateCharts
		{
			get { return this._canCreateCharts; }
			set { this._canCreateCharts = value; }
		}

		[DataMember]
		public BooleanManagedProperty CanBeRelatedEntityInRelationship
		{
			get { return this._canBeRelatedEntityInRelationship; }
			internal set { this._canBeRelatedEntityInRelationship = value; }
		}

		[DataMember]
		public BooleanManagedProperty CanBePrimaryEntityInRelationship
		{
			get { return this._canBePrimaryEntityInRelationship; }
			internal set { this._canBePrimaryEntityInRelationship = value; }
		}

		[DataMember]
		public BooleanManagedProperty CanBeInManyToMany
		{
			get { return this._canBeInManyToMany; }
			internal set { this._canBeInManyToMany = value; }
		}

		[DataMember]
		public BooleanManagedProperty CanModifyAdditionalSettings
		{
			get { return this._canModifyAdditionalSettings; }
			set { this._canModifyAdditionalSettings = value; }
		}

		[DataMember]
		public bool? IsImportable
		{
			get { return this._isImportable; }
			internal set { this._isImportable = value; }
		}

		[DataMember]
		public bool? IsIntersect
		{
			get { return this._isIntersect; }
			internal set { this._isIntersect = value; }
		}

		[DataMember]
		public BooleanManagedProperty IsMailMergeEnabled
		{
			get { return this._isMailMergeEnabled; }
			set { this._isMailMergeEnabled = value; }
		}

		[DataMember]
		public bool? IsManaged
		{
			get { return this._isManaged; }
			internal set { this._isManaged = value; }
		}

		[DataMember]
		public bool? IsEnabledForCharts
		{
			get { return this._isEnabledForCharts; }
			internal set { this._isEnabledForCharts = value; }
		}

		[DataMember]
		public bool? IsValidForAdvancedFind
		{
			get { return this._isValidForAdvancedFind; }
			internal set { this._isValidForAdvancedFind = value; }
		}

		[DataMember]
		public BooleanManagedProperty IsVisibleInMobile
		{
			get { return this._isVisibleInMobile; }
			set { this._isVisibleInMobile = value; }
		}

		[DataMember]
		public bool? IsReadingPaneEnabled
		{
			get { return this._isReadingPaneEnabled; }
			set { this._isReadingPaneEnabled = value; }
		}


		// Not valid for create
		// Valid as key for update
		[DataMember]
		public string LogicalName
		{
			get { return this._logicalName; }
			set { this._logicalName = value; }
		}

		[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
		[DataMember]
		public ManyToManyRelationshipMetadata[] ManyToManyRelationships
		{
			get { return this._manyToManyRelationships; }
			internal set { this._manyToManyRelationships = value; }
		}

		[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
		[DataMember]
		public OneToManyRelationshipMetadata[] ManyToOneRelationships
		{
			get { return this._manyToOneRelationships; }
			internal set { this._manyToOneRelationships = value; }
		}

		[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
		[DataMember]
		public OneToManyRelationshipMetadata[] OneToManyRelationships
		{
			get { return this._oneToManyRelationships; }
			internal set { this._oneToManyRelationships = value; }
		}

		[DataMember]
		public int? ObjectTypeCode
		{
			get { return this._objectTypeCode; }
			internal set { this._objectTypeCode = value; }
		}

		[DataMember]
		public OwnershipTypes? OwnershipType
		{
			get { return this._ownershipType; }
			set { this._ownershipType = value; }
		}

		[DataMember]
		public string PrimaryNameAttribute
		{
			get { return this._primaryNameAttribute; }
			internal set { this._primaryNameAttribute = value; }
		}

		[DataMember]
		public string PrimaryIdAttribute
		{
			get { return this._primaryIdAttribute; }
			internal set { this._primaryIdAttribute = value; }
		}

		[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
		[DataMember]
		public SecurityPrivilegeMetadata[] Privileges
		{
			get { return this._privileges; }
			internal set { this._privileges = value; }
		}

		[DataMember]
		public string RecurrenceBaseEntityLogicalName
		{
			get { return this._recurrenceBaseEntityLogicalName; }
			// Making setter internal so it will become read-only for outer world.
			internal set { this._recurrenceBaseEntityLogicalName = value; }
		}

		[DataMember]
		public string ReportViewName
		{
			get { return this._reportViewName; }
			internal set { this._reportViewName = value; }
		}

		[DataMember]
		public string SchemaName
		{
			get { return this._schemaName; }
			set { this._schemaName = value; }
		}

		internal int? WorkflowSupport
		{
			get { return this._workflowSupport; }
			set { this._workflowSupport = value; }
		}

		internal string PhysicalName
		{
			get { return this._physicalName; }
			set { this._physicalName = value; }
		}
	}
}
